using Xamarin.Forms;

namespace Outcoder.UI.Xaml
{
	public class AppBarItemFactory : IAppBarItemFactory
	{
		public virtual IAppBarItem BuildItem(IUICommand command)
		{
			ArgumentValidator.AssertNotNull(command, "command");

			var result = new AppBarItem {Command = command};
			result.SetBinding(AppBarItem.TextProperty, new Binding("Text"));
			result.SetBinding(AppBarItem.IconUriProperty, new Binding("IconUrl", BindingMode.OneWay, new StringToUriConverter()));
			result.SetBinding(AppBarItem.IsEnabledProperty, new Binding("Enabled", BindingMode.OneWay));

			return result;
		}
	}

	public interface IAppBarItemFactory
	{
		IAppBarItem BuildItem(IUICommand command);
	}
}